import {createSlice} from '@reduxjs/toolkit'
import store2 from 'store2'
interface IAdminstate {
    adminname:string,
    token:string
}
const initialState:IAdminstate = {
    adminname:store2.get('adminname'),
    token:store2.get('token'),
}

const adminSlice = createSlice({
    name: 'admin',
    initialState,
    reducers:{
        Changeadminname(state: { adminname: any },action: { payload: any }){
            state.adminname = action.payload
            store2.set('adminname',action.payload)
        },
        Changetoken(state: { token: any },action: { payload: any }){
            state.token = action.payload
            store2.set('token',action.payload)
        },
        ChangecheckedKeys(state,action){
            state.token = action.payload
            store2.set('checkedKeys',action.payload)
        }
    }
})

export const {Changeadminname ,Changetoken,ChangecheckedKeys} = adminSlice.actions
export default adminSlice.reducer